<!--
描述：办公自动化-流程进度查看管理组件，显示流程进度图片
开发人：sunlf
开发日期：2017年8月17日
-->
<template lang="pug">
  div
    kalix-dialog(v-bind:title="title" v-bind:visible="visible" ref="kalixBizDialog"
    v-bind:close-on-click-modal="false" v-bind:formModel="formModel" v-bind:isView="isView")
      div.imgs(v-bind:id="keyId" ref="imgs" slot="dialogFormSlot")
        img(v-if="isShow" v-bind:src="imgUrl" style="width:100%")
</template>

<script type="text/ecmascript-6">
  // import {ON_INIT_DIALOG_DATA} from '@/components/custom/event.toml'
  // import {baseURL} from 'config/global.toml'
  // import EventBus from 'common/eventbus'
  // import Dialog from '@/components/custom/baseDialog.vue'
  // import {Loading} from 'element-ui'
  // console.log('this.$KalixGlobalConfig-------------', this.$KalixGlobalConfig)
  // let loadingInstance

  export default {
    name: 'OaTaskView',
    data() {
      return {
        bizKey: 'processTask',
        title: '',
        visible: false,
        isView: true,
        imgUrl: '',
        formModel: {},
        keyId: null,
        isShow: false
      }
    },
    created() {
    },
    mounted() {
      this.baseURL = this.$KalixGlobalConfig.baseURL
      this.viewURL = this.baseURL + `/image?taskId=`
      this.viewProcessURL = this.baseURL + `/image?processInstanceId=`
      this.$KalixEventBus.$on(this.bizKey + '-' + this.$KalixEventConfig.ON_INIT_DIALOG_DATA, this.initData)
    },
    components: {
      // KalixDialog: Dialog
    },
    methods: {
      initData(row) {
        this.keyId = `OaTaskViewDialog_${Math.floor(Math.random() * 10000)}`
        this.isShow = false
        this.title = '流程进度查看-' + row.businessNo
        this.$nextTick(() => {
          let loading = this.$loading({
            target: `#${this.keyId}`,
            fullscreen: false
          })
          setTimeout(() => {
            loading.close()
            this.isShow = true
            if (row.processInstanceId) { // 按流程实例id显示当前进度
              this.imgUrl = this.viewProcessURL + row.processInstanceId
            } else { // 按taskid显示当前进度
              this.imgUrl = this.viewURL + row.id
            }
          }, 500)
        })
      }
    }
  }
</script>

<style scoped lang="stylus">

</style>
